import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FontUtil } from "../../../common/font/FontUtil";
import { Language } from "../../../../extend/language/Language";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
import { TeamBuyRuleTip } from "./TeamBuyRuleTip";
import { GTextFormat } from "../../../common/GTextFormat";
import { MyTeamBuyMoneyView } from "./MyTeamBuyMoneyView";
import { TextAlign } from "../../../../flashx/textLayout/formats/TextAlign";
import { BaseItemNormal } from "../common/item/BaseItemNormal";
import { ItemData } from "../../resource/info/ItemData";
import { ResFileConst } from "../../resource/ResFileConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { EPrictUnit } from "../../../../Message/Public/EPrictUnit";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class BottomBody
    
    export  class BottomBody /* flash.events.EventDispatcher */
    {
        constructor(arg1: Object /* flash.display.Sprite */)
        {
            
            this.varMap = new Map<any, any> /* flash.utils.Dictionary */(false);
            this.box = arg1;
            this.createBottom();
            return;
        }

        /* internal  */createBottom(): void
        {
            ObjCreate.createFlowerBg(17, 396, 674, 136, this.box, true, "LT,RT");
            var loc1=ObjCreate.createBitmap(ImagesConst.RechargeFlwBg, 232, 403, this.box);
            var loc2=ObjCreate.createBitmap(ImagesConst.RechargeFlwBg, 472, 403, this.box);
            loc2.rotationY = -180;
            ObjCreate.createBg(190, 423, 190, 1, this.box, ImagesConst.KillUserLine);
            var loc3=GlobalStyle.textFormat6;
            loc3.font = FontUtil.EmbedTitleName;
            loc3.size = 22;
            ObjCreate.createEmbedTextFiled(Language.getString(85033), 298, 401, 150, 20, this.box, loc3);
            var loc4;
            (loc4 = GlobalStyle.textFormat1).bold = true;
            loc4.letterSpacing = 1;
            var loc5=ObjCreate.createTextField(Language.getString(85034), 390, 434, 100, 20, this.box, loc4, true);
            var loc6=ObjCreate.createTextField(Language.getString(85035), 390, 455, 100, 20, this.box, loc4, true);
            var loc7=ObjCreate.createTextField(Language.getString(85045), 390, 476, 100, 20, this.box, loc4, true);
            ToolTipsManager.register(loc5, TeamBuyRuleTip, Language.getString(85046));
            ToolTipsManager.register(loc6, TeamBuyRuleTip, Language.getString(85047));
            ToolTipsManager.register(loc7, TeamBuyRuleTip, Language.getString(85048));
            var loc8;
            (loc8 = new GTextFormat(FontUtil.xingkaiName, 18, GlobalStyle.color5Uint)).letterSpacing = 2;
            this.curPriceTF2 = ObjCreate.createTextField("199", 486, 432, 65, 27, this.box, loc8);
            this.nextPriceTF = ObjCreate.createTextField("300", 486, 453, 100, 27, this.box, loc8);
            this.opengTeamBuyNum = ObjCreate.createTextField("300", 486, 473, 100, 27, this.box, loc8);
            this.hasTopLeveTF = ObjCreate.createTextField(Language.getString(85036), 467, 455, 96, 27, this.box, GlobalStyle.textFormat5);
            this.hasTopLeveTF.visible = false;
            this.myTeamBuyInfoText = new MyTeamBuyMoneyView();
            this.myTeamBuyInfoText.updataMoney(0, 2);
            ObjCreate.setObjAttri(this.myTeamBuyInfoText, 390, 507, -1, -1, this.box);
            var loc9;
            (loc9 = GlobalStyle.textFormat1).align = TextAlign.CENTER;
            var loc10;
            (loc10 = GlobalStyle.textFormat1).align = TextAlign.RIGHT;
            this.createLeve(0, 0, 699, loc9, loc10);
            this.createLeve(1, 50, 599, loc9, loc10);
            this.createLeve(2, 150, 499, loc9, loc10);
            this.createLeve(3, 300, 399, loc9, loc10);
            this.createLeve(4, 500, 299, loc9, loc10);
            this.createLeve(5, 800, 99, loc9, loc10);
            ObjCreate.createBg(548, 462, 142, 1, this.box, ImagesConst.SplitLine);
            var loc11;
            (loc11 = GlobalStyle.textFormat5).leading = 7;
            loc11.align = flash.text.TextFormatAlign.CENTER;
            var loc12;
            (loc12 = ObjCreate.createTextField(Language.getString(85017), 551, 419, 92, 40, this.box, loc11, true, false)).autoSize = flash.text.TextFieldAutoSize.CENTER;
            var loc13;
            (loc13 = new BaseItemNormal()).setSize(32, 32);
            loc13.isDragAble = false;
            loc13.isDropAble = false;
            var loc14=new ItemData(14011175);
            loc13.itemData = loc14;
            ObjCreate.setObjAttri(loc13, 645, 420, -1, -1, this.box);
            ObjCreate.createBg(547, 401, 1, 121, this.box, ImagesConst.VSpliteLine);
            this.joinBtn = ObjCreate.createGLoadedButton(ResFileConst.TeamBuyBtn, 571, 470, 97, 50, this.box);
            this.joinBtn.addEventListener(flash.events.MouseEvent.CLICK, this.clickBtnHander);
            this.joinBtn.filters = [FilterConst.colorFilter];
            return;
        }

        /* internal  */clickBtnHander(arg1: Object /* flash.events.Event */): void
        {
            if (this.joinBtn.filters && this.joinBtn.filters.length == 1) 
            {
                return;
            }
            this.dispatchEvent(new Object /* flash.events.Event */("#jongTeamBuy#"));
            return;
        }

        public updataBottomInfo(arg1: Array<any>, arg2: int, arg3: Boolean, arg4: int, arg5: int, arg6: int): void
        {
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc12=0;
            var loc13=null;
            var loc14=0;
            var loc1;
            var loc2=loc1 = arg1.length;
            var loc3=false;
            var loc8=this.varMap["levelImg" + loc12];
            var loc9=GlobalStyle.color1Uint;
            var loc10=Language.getString(85027);
            var loc11=0;
            while (loc11 < 6) 
            {
                loc7 = this.varMap["level" + loc11 + "_box"];
                if (loc11 < loc1) 
                {
                    loc4 = this.varMap["level" + loc11 + "_top"];
                    loc5 = this.varMap["level" + loc11];
                    loc8 == this.varMap["levelImg" + loc11];
                    loc6 = this.varMap["level" + loc11 + "_moneyIcon"];
                    loc14 = (loc13 = arg1[loc11]).personNum;
                    loc4.text = "" + loc14 + loc10;
                    loc5.text = "" + loc13.ybNum;
                    var loc15;
                    loc4.textColor = loc15 = loc9;
                    loc5.textColor = loc15;
                    if (arg5 != EPrictUnit._EPriceUnitGold) 
                    {
                        loc6.bitmapData = GlobalClass.getBitmapData(ImagesConst.Tongqian_small);
                    }
                    else 
                    {
                        loc6.bitmapData = GlobalClass.getBitmapData(ImagesConst.Yuanbao_small);
                    }
                    loc7.visible = true;
                    if (loc14 > arg2 && !loc3) 
                    {
                        loc2 = loc11;
                        loc3 = true;
                    }
                }
                else 
                {
                    loc7.visible = false;
                }
                ++loc11;
            }
            --loc12;
            this.curPriceTF2.text = String(arg2);
            if (loc12 < (loc1 - 1)) 
            {
                this.nextPriceTF.text = String(arg1[loc2].personNum - arg2);
                this.hasTopLeveTF.visible = false;
            }
            else 
            {
                this.nextPriceTF.text = "";
                this.hasTopLeveTF.visible = true;
            }
            this.opengTeamBuyNum.text = String(arg6);
            if (!this.curLevelBitmap) 
            {
                this.curLevelBitmap = ObjCreate.createBg(0, 0, 31, 50, loc7, ImagesConst.TeamBuy_level_over);
            }
            loc8 = this.varMap["levelImg" + loc12];
            this.curLevelBitmap.width = loc8.width;
            this.curLevelBitmap.height = loc8.height;
            this.curLevelBitmap.x = loc8.x;
            this.curLevelBitmap.y = loc8.y;
            loc4 = this.varMap["level" + loc12 + "_top"];
            loc5 = this.varMap["level" + loc12];
            loc5.textColor = loc15 = GlobalStyle.color5Uint;
            loc4.textColor = loc15;
            if (arg3) 
            {
                this.joinBtn.filters = [FilterConst.colorFilter];
                this.myTeamBuyInfoText.updataMoney(arg4, arg5);
            }
            else 
            {
                this.joinBtn.filters = null;
                this.myTeamBuyInfoText.updataMoney(0, arg5);
            }
            return;
        }

        /* internal  */createLeve(arg1: int, arg2: int, arg3: int, arg4: Object /* flash.text.TextFormat */, arg5: Object /* flash.text.TextFormat */): void
        {
            var loc11=0;
            var loc1=60;
            var loc2=31;
            var loc3=25;
            var loc4=20;
            var loc5=512;
            var loc6=3 / 50;
            var loc7=loc4 + int(loc6 * arg2);
            var loc8=loc3 + arg1 * loc1;
            var loc9=new Object /* flash.display.Sprite */();
            this.box.addChild(loc9);
            this.varMap["level" + arg1 + "_box"] = loc9;
            var loc10="" + arg2 + Language.getString(85027);
            this.varMap["level" + arg1 + "_top"] = ObjCreate.createTextField(loc10, loc8, loc5 - loc7 - 15, loc1, 16, loc9, arg4);
            this.varMap["levelImg" + arg1] = ObjCreate.createBg(loc8 + int((loc1 - loc2) / 2), loc5 - loc7, loc2, loc7, loc9, ImagesConst.TeamBuy_level_normal);
            this.varMap["level" + arg1] = ObjCreate.createTextField("" + arg3, loc8 + 5, loc5, 28, 16, loc9, arg5);
            this.varMap["level" + arg1 + "_moneyIcon"] = ObjCreate.createBitmap(ImagesConst.Yuanbao_small, loc8 + 30, loc5, loc9);
            if (arg1 != 0) 
            {
                loc11 = loc7 + 30;
                ObjCreate.createBg(loc8, loc5 - loc11 + 10, 1, loc11, loc9, ImagesConst.VSpliteLine);
            }
            return;
        }

        /* internal */ /* var */box: Object /* flash.display.Sprite */;

        /* internal */ /* var */joinBtn: GLoadedButton;

        /* internal */ /* var */curPriceTF2: Object /* flash.text.TextField */;

        /* internal */ /* var */nextPriceTF: Object /* flash.text.TextField */;

        /* internal */ /* var */opengTeamBuyNum: Object /* flash.text.TextField */;

        /* internal */ /* var */curLevelBitmap: ScaleBitmap;

        /* internal */ /* var */varMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */myTeamBuyInfoText: MyTeamBuyMoneyView;

        /* internal */ /* var */hasTopLeveTF: Object /* flash.text.TextField */;
    }
